$(function () {
    initMap();
});

function initMap() {
    var param = {};
    param.areaName = "西安";
    map = MapUtil.createMap("map", {}, param);

    var heatmapOverlay = MapUtil.createHeatMap(map, getData());

    setInterval(function () {
        MapUtil.reflashHeatMap(heatmapOverlay, getData());
    }, 5000);

    var drawingManager = MapUtil.drawingManager(map, function (param) {
        var inarr = [];

        var polygon = param["curAreaOverlayInfo"];
        var datas = getData();
        for (var i = 0; i < datas.length; i++) {
            var d = datas[i];
            if (BMapLib.GeoUtils.isPointInPolygon(new BMap.Point(d.lng, d.lat), polygon)) {
                inarr.push(d);
            }
        }
        MapUtil.createPoints(inarr)
    });
}

function getData() {
    var data = laccis;

    for (var i = 0; i < data.length; i++) {
        var count = randomNum(100, 10000);
        data[i]["count"] = count;
    }

    return data;
}